package com.woniuxy.lrz.carlproject.common.util;

import com.woniuxy.lrz.carlproject.common.Result;
import lombok.Data;

import java.io.Serializable;

@Data
public class Results<T> implements Serializable {
    private Integer code;
    //    private Boolean flag;
    private String message;
    private T data;

    public static Results instance(){
        Results result=new Results();
        result.setCode(200);
        result.setMessage("访问成功");
        return result;
    }
    public Integer getCode() {
        return code;
    }

    public Results setCode(Integer code) {
        this.code = code;
        return this;
    }

//    public Boolean getFlag() {
//        return flag;
//    }
//
//    public Result setFlag(Boolean flag) {
//        this.flag = flag;
//        return this;
//    }

    public String getMessage() {
        return message;
    }

    public Results setMessage(String message) {
        this.message = message;
        return this;
    }

    public T getData() {
        return data;
    }

    public Results setData(T data) {
        this.data = data;
        return this;
    }

    public static Results success(Integer code, String message, Object data){
        Results result = new Results();
//        result.setFlag(true);
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static Results fail(Integer code, String message){
        Results result = new Results();
//        result.setFlag(false);
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}
